package com.llap.exp190929.controller;

import com.llap.exp190929.dto.PaginatedDto;
import com.llap.exp190929.entity.UserType;
import com.llap.exp190929.service.UserTypeService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by LLAP on 2019/10/14.
 * Copyright (c) 2019 LLAP. All rights reserved.
 */
@RestController
@RequestMapping("usertypes")
@AllArgsConstructor
@CrossOrigin
@Slf4j
public class UserTypesController {
    private UserTypeService userTypeService;

    @GetMapping("")
    public List<UserType> findUserTypes() {
        return userTypeService.findAll();
    }

    @GetMapping("{id}")
    public UserType findUserType(@PathVariable Integer id) {
        return userTypeService.findUserType(id);
    }

    @PostMapping("")
    public UserType addUserType(@RequestBody UserType usertype) {
        return userTypeService.addUserType(usertype);
    }

    @DeleteMapping("")
    public void deleteUserType(@RequestParam Integer id) {
        userTypeService.deleteUserType(id);
    }

    @PatchMapping("")
    public UserType updateUserType(@RequestBody UserType usertype) {
        return userTypeService.updateUserType(usertype);
    }
}
